package com.example.lottoscratcho;

import org.andengine.entity.scene.Scene;
import org.andengine.ui.activity.BaseGameActivity;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.WakeLockOptions;
import org.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;

public class MainActivity extends BaseGameActivity {

//---------------------------------------------------------------------------FIELDS:	
	
	public final static int CAMERA_WIDTH = 768;
	public final static int CAMERA_HEIGHT = 1280;
	public final static int CENTER_X = 384;
	public final static int CENTER_Y = 640;

	Camera mCamera;				//andEngine's Camera object
	Scene mScene;				//andEngine's Scene object (current scene)
	SceneManager sceneManager;
	
//--------------------------------------------------------------------------METHODS:	
	
	@Override
	public EngineOptions onCreateEngineOptions() {
	
		//Define mCamera object
		mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
		
		//Declare engine options;
		EngineOptions options = new EngineOptions(true,
												  ScreenOrientation.PORTRAIT_FIXED,
												  new FillResolutionPolicy(),			//new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT),		//Application will maintian width-height ratio
												  mCamera);
		
		//Keep screen from turning off during gameplay (due to inactivity)
		options.setWakeLockOptions(WakeLockOptions.SCREEN_ON);						//May not keep this
		
		return options;	
		
	}

	@Override
	public void onCreateResources(OnCreateResourcesCallback resourceCallback) {
		
		//Create our Scene Manager
		SceneManager.setUpSceneManager(this, mEngine, mCamera);

		//Get a local reference to it (just for readability)
		sceneManager = SceneManager.getInstance();
		
		sceneManager.loadResources(Scenes.SPLASH);
		
		//Notify callback that we've finished creating resources
		resourceCallback.onCreateResourcesFinished();
		
	}

	@Override
	public void onCreateScene(OnCreateSceneCallback sceneCallback) {

		//Create Scene object
		mScene = sceneManager.createScene(Scenes.SPLASH);
		
		//Notify callback that we've created the scene
		sceneCallback.onCreateSceneFinished(mScene);
		
	}

	@Override
	public void onPopulateScene(Scene pScene,
								OnPopulateSceneCallback sceneCallback) {
		
		sceneManager.populateScene(Scenes.SPLASH);
		
		//Notify callback that we've populated the scene
		sceneCallback.onPopulateSceneFinished();
		
	}
	
//--------------------------------------------------------------------------HELPERS:
	
	public Scene getScene() {
		return mScene;
	}
	
	public void setScene(Scene newScene) {
		mScene = newScene;
	}
	
	
}
